Devinがpdfjs-dist npmの更新でNode.js 20.4以上が必要な事をつきとめ、polyfillを作って解決してくれた
dependabotの作ったライブラリ更新プルリクをshokaiが重視している観点でDevinにレビューさせたり、リリースノート読ませてアプリ側のコードも修正させたりするを使ったshokai.icon
Bump pdfjs-dist from 4.0.379 to 4.2.67 in /cloud-functions/read-file-text #7337 by Dependabot.icon
PDFファイル内のテキストをElasticsearchにindexして全文検索するの、PDFからテキスト取得するcloud functionのnpm更新
更新したらpdfjs-distのAPIが変わって動かなくなった
code:error
D readFileText-local-dev au4ngpd29bd9 2025-04-17 21:52:46.662 Function execution started
E readFileText-local-dev m71jta1e8owh 2025-04-17 21:19:00.160 TypeError: Promise.withResolvers is not a function
at new PDFDocumentLoadingTask (file:///workspace/node_modules/pdfjs-dist/build/pdf.mjs:3026:32)
at getDocument (file:///workspace/node_modules/pdfjs-dist/build/pdf.mjs:2838:16)
at readPDFText (file:///workspace/contentType/pdf.js:15:17)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async httpHandler (file:///workspace/index.js:53:20)
D readFileText-local-dev m71jta1e8owh 2025-04-17 21:18:59.096 Function execution took 933 ms, finished with status code: 500
cloud functionが500 server errorを返している
cloud functionのNode.jsを全て20に更新 #7359 by shokai.icon
別途Cosenseのcloud functionをnode.js v20に更新するのために作っていた
Devin.iconがPromise.withResolversはNode.js v20.4から使えると言うので、Dependabot.iconのpull requestにmergeした
PDFJSのバージョンアップデートに対応するPromise.withResolversポリフィルを追加 #7360 by Devin.icon
Node20にしたけどまだPromise.withResolvers無いよって言ったら、Devin.iconがPolyfill作ってくれた
cloud functionのnode.jsは20を指定しても20.4未満なのかな多分
https://app.devin.ai/sessions/c4791d5b8e8e4c5ba8730b07111169f6
https://gyazo.com/646d8b914531afc2182a7f4da12ae427
PDFからテキスト取得できるようになった
https://gyazo.com/d2106a770a11a419326d1b3a46a3b37f